package com.phantom.reflection.question;

import com.phantom.Cat;

import java.io.FileInputStream;
import java.lang.reflect.Method;
import java.util.Properties;

public class ReflectionQuestion {
    public static void main(String[] args) throws Exception {

        Properties properties = new Properties();
        properties.load(new FileInputStream("src\\main\\resources\\re.properties"));
        String classfullpath = properties.get("classfullpath").toString();

        String methodName = properties.get("method").toString();

        System.out.println("classfullpath:" + classfullpath);
        System.out.println("methodName: " + methodName);

        Class cls = Class.forName(classfullpath);
        Cat cat = (Cat) cls.newInstance();
        System.out.println("o的运行类型：" + cat.getClass());
        Method method1 = cls.getMethod(methodName);
        System.out.println("method: " + method1);

        System.out.println("=================");
        method1.invoke(cat); // 传统方法：对象.方法    反射机制：方法.invoke(对象)

    }
}
